Test#

Test button#

Hide code cell source
import matplotlib.pyplot as plt
plt.figure(figsize=(10, 6),facecolor='white')
plt.plot([0, 1, 2], [0, 1, 4])
plt.title("Example Plot")
plt.show()
../_images/1b1175fe5552bba5403c1c89a3cb70fc215e22ff5ccbfadfdaae880e1d8b7098.png

Plotly Display#

Hide code cell source
import plotly.io as pio
import plotly.express as px
import plotly.offline as py

df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species", size="sepal_length")
fig
import plotly.graph_objects as go
import plotly.io as pio

# Set the renderer to 'notebook'
pio.renderers.default = 'notebook'

# Create a basic figure
fig = go.Figure(data=go.Bar(y=[2, 3, 1]))

# Display the figure
fig.show()
import plotly.graph_objects as go
from plotly.subplots import make_subplots

# Sample data
time = list(range(1000))
pose = [i * 0.5 for i in time]  # Example time series data for pose

# Action data
actions = ['walk', 'run', 'idle'] * (len(time) // 3 + 1)
action_times = [(i * 10, (i + 1) * 10) for i in range(len(time) // 10)]
action_colors = {
    'walk': 'blue',
    'run': 'red',
    'idle': 'green'
}

# Create subplots
fig = make_subplots(rows=2, cols=1, shared_xaxes=True, vertical_spacing=0.1,
                    subplot_titles=("Time Series of Pose", "Action Sequence"))

# Add time series to the top subplot
fig.add_trace(go.Scatter(x=time, y=pose, mode='lines', name='Pose'), row=1, col=1)

# Add dummy traces for legend
for action in action_colors.keys():
    fig.add_trace(go.Scatter(
        x=[None], y=[None], mode='markers',
        marker=dict(size=10, color=action_colors[action]),
        name=action
    ), row=2, col=1)

# Add action rectangles to the bottom subplot
for action, (start, end) in zip(actions, action_times):
    fig.add_trace(go.Scatter(
        x=[start, end, end, start, start],
        y=[0, 0, 1, 1, 0],
        fill="toself",
        fillcolor=action_colors[action],
        line=dict(color="rgba(0,0,0,0)"),
        showlegend=False,
        hoverinfo='none'
    ), row=2, col=1)

# Update layout for better visualization
fig.update_layout(height=600, width=1000, title_text="Ethogram Visualization",
                  xaxis2=dict(rangeslider=dict(visible=True),
                              type="linear"))

fig.update_yaxes(visible=False, row=2, col=1)  # Hide y-axis for the action subplot
fig.update_xaxes(title_text="Time", row=2, col=1)
fig.update_yaxes(title_text="Pose", row=1, col=1)

fig.show()
.. toggle:: Click here to show/hide the code
   :show:

   .. code-block:: python

       import matplotlib.pyplot as plt

       plt.figure(figsize=(10, 6))
       plt.plot([0, 1, 2], [0, 1, 4])
       plt.title("Example Plot")
       plt.show()
  Cell In[5], line 1
    .. toggle:: Click here to show/hide the code
    ^
SyntaxError: invalid syntax